package com.daocao.common.service.impl;

import cn.hutool.core.util.ObjectUtil;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daocao.common.constants.HttpStatus;
import com.daocao.common.domain.entity.UmsRole;
import com.daocao.common.exception.ServiceException;
import com.daocao.common.mapper.UmsRoleMapper;
import com.daocao.common.service.ISysUserService;
import com.daocao.common.utils.security.DaoCaoSecurityUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @date 
 * @date 
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<UmsRoleMapper,UmsRole> implements ISysUserService {

    @Autowired
    private UmsRoleMapper roleMapper;


    @Override
    public Long searchRoleInfo() {
        // 获取用户id
        Long userId = DaoCaoSecurityUtil.getUserId();
        Long roleId = roleMapper.selectByUserId(userId);
        if(ObjectUtil.isNull(roleId)) {
            throw new ServiceException(HttpStatus.FORBIDDEN,"");
        }
        return roleId;
    }


}